**Replication code for Cody Eldredge & Matthew Fails, "When do Autocrats Create Sovereign Wealth Funds?", forthcoming in Political Research Quarterly 

*Contact: Matthew Fails, fails@oakland.edu

*********************

*Do file requires the following packages:
	* schemepack
	* blindschemes
	* kountry 
*type 'ssc install [name of package]'

**********************

clear


*remove the * from the following line of code and include the full file location for the replication data. Replication dataset is titled "EldredgeFailsReplicationData.dta"

*use "...\EldredgeFailsReplicationData.dta"

***********************
*Describe all variables in dataset
***********************

des

*'gwf' prefix variables and those with GWF in variable description are from Geddes, Wright, and Frantz (2018)
*All other variable labels include source

************************
**Create relevant variables
************************

*Binary measure of existence of sovereign wealth fund (See Eldredge 2019, The World Economy, )

// countries by COW
gen swf = 0
replace swf = 1 if ccode == 900 & year >= 2006 // Australia
replace swf = 1 if ccode == 373 & year >= 1999 // Azerbaijan
replace swf = 1 if ccode == 692 & year >= 2006 // Bahrain
replace swf = 1 if ccode == 571 & year >= 1993 // Botswana
replace swf = 1 if ccode == 155 & year >= 2006 // Chile - fund created by Bachelet in 2006 after she took office from Pinera 
replace swf = 1 if ccode == 710 & year >= 2007 // China
replace swf = 1 if ccode == 411 & year >= 2002 // Equatorial Guinea
replace swf = 1 if ccode == 630 & year >= 1999 // Iran 
replace swf = 1 if ccode == 205 & year >= 2001 // Ireland 
replace swf = 1 if ccode == 690 & year >= 1953 // Kuwait
replace swf = 1 if ccode == 620 & year >= 2006 // Libya     
replace swf = 1 if ccode == 70 & year >=  2000 // Mexico - first fund created by Zedillo before Fox took office in late 2000
replace swf = 1 if ccode == 385 & year >= 1967 // Norway
replace swf = 1 if ccode == 698 & year >= 1980 // Oman
replace swf = 1 if ccode == 694 & year >= 2005 // Qatar 
replace swf = 1 if ccode == 365 & year >= 2007 // Russia 
replace swf = 1 if ccode == 830 & year >= 1974 // Singapore 
replace swf = 1 if ccode == 732 & year >= 2005 // South Korea 
replace swf = 1 if ccode == 860 & year >= 2005 // East Timor
replace swf = 1 if ccode == 52 & year >=  2007 // Trinidad & Tobago
replace swf = 1 if ccode == 696 & year >= 1967 // United Arab Emirates
replace swf = 1 if ccode == 816 & year >= 2006 // Vietnam
replace swf = 1 if ccode == 698 & year >= 1980 // Oman
replace swf = 1 if ccode == 615 & year >= 2000 // Algeria
replace swf = 1 if ccode == 540 & year >= 2012 // Angola
replace swf = 1 if ccode == 140 & year >= 2008 // Brazil
replace swf = 1 if ccode == 835 & year >= 1983 // Brunei
replace swf = 1 if ccode == 220 & year >= 2008 // France    
replace swf = 1 if ccode == 481 & year >= 1998 // Gabon 
replace swf = 1 if ccode == 452 & year >= 2011 // Ghana 
replace swf = 1 if ccode == 850 & year >= 2006 // Indonesia
replace swf = 1 if ccode == 645 & year >= 2003 // Iraq
replace swf = 1 if ccode == 325 & year >= 2011 // Italy - created by Berlesconi before Monti took office 
replace swf = 1 if ccode == 705 & year >= 2000 // Kazakhstan
replace swf = 1 if ccode == 946 & year >= 1956 // Kiribati
replace swf = 1 if ccode == 820 & year >= 1993 // Malaysia
replace swf = 1 if ccode == 435 & year >= 2006 // Mauritania
replace swf = 1 if ccode == 135 & year >= 1999 // Peru
replace swf = 1 if ccode == 101 & year >= 1998 // Venezuela       
replace swf = 1 if ccode == 712 & year >= 2011 // Mongolia
replace swf = 1 if ccode == 920 & year >= 2003 // New Zealand
replace swf = 1 if ccode == 475 & year >= 2011 // Nigeria
replace swf = 1 if ccode == 95 & year  >= 2012 // Panama
replace swf = 1 if ccode == 910 & year >= 2010 // Papua New Guinea
replace swf = 1 if ccode == 670 & year >= 2008 // Saudi Arabia
replace swf = 1 if ccode == 433 & year >= 2012 // Senegal - created by Macky Sall after he took office
replace swf = 1 if ccode == 701 & year >= 2008 // Turkmenistan
replace swf = 1 if ccode == 375 & year >= 2008 // Finland 



******************
*Limit sample to only autocratic country-years
******************
drop if gwf_caseid==.

******************
*Table 1
******************
/*
We calculate the share of party-autocracy years for two different samples: the autocracies that never created a SWF, and the autocracies that did. Specifically, for countries that never create a SWF, this uses the entire time period (1960-2010). For countries that do create a SWF, this uses the year 1960 until and including the year the SWF was created. Then these measures are used to create a ratio variable measuring the share of autocratic years where a party system was in power
*/

*first generate a count of total years per country
sort ccode year
by ccode: egen last_yr = max(year)
by ccode: egen first_yr = min(year)
by ccode: generate total_yr = (last_yr - first_yr)+1

*then generate a count of years under party autocracy
by ccode: gen party_yr = 0
by ccode: replace party_yr = 1 if gwf_party ==1
by ccode: egen total_party_yr = sum(party_yr)

*then generate a ratio variable 
by ccode: gen party_share = total_party_yr / total_yr
label var party_share "Share of autocratic country-years under party autocracy"

*For swf==1, will need to recreate party_share for years prior to SWF creation

* ID variable that says whether the country creates a SWF at some point. 
* Then,  calculate party_share for the years where swf=0, but if SWF sample ==1 

gen	swf_sample	=	0				
replace	swf_sample	=	1	if	ccode	==	900
replace	swf_sample	=	1	if	ccode	==	373
replace	swf_sample	=	1	if	ccode	==	692
replace	swf_sample	=	1	if	ccode	==	571
replace	swf_sample	=	1	if	ccode	==	155
replace	swf_sample	=	1	if	ccode	==	710
replace	swf_sample	=	1	if	ccode	==	411
replace	swf_sample	=	1	if	ccode	==	630
replace	swf_sample	=	1	if	ccode	==	205
replace	swf_sample	=	1	if	ccode	==	690
replace	swf_sample	=	1	if	ccode	==	620
replace	swf_sample	=	1	if	ccode	==	70
replace	swf_sample	=	1	if	ccode	==	385
replace	swf_sample	=	1	if	ccode	==	698
replace	swf_sample	=	1	if	ccode	==	694
replace	swf_sample	=	1	if	ccode	==	365
replace	swf_sample	=	1	if	ccode	==	830
replace	swf_sample	=	1	if	ccode	==	732
replace	swf_sample	=	1	if	ccode	==	860
replace	swf_sample	=	1	if	ccode	==	52
replace	swf_sample	=	1	if	ccode	==	696
replace	swf_sample	=	1	if	ccode	==	816
replace	swf_sample	=	1	if	ccode	==	698
replace	swf_sample	=	1	if	ccode	==	615
replace	swf_sample	=	1	if	ccode	==	540
replace	swf_sample	=	1	if	ccode	==	140
replace	swf_sample	=	1	if	ccode	==	835
replace	swf_sample	=	1	if	ccode	==	220
replace	swf_sample	=	1	if	ccode	==	481
replace	swf_sample	=	1	if	ccode	==	452
replace	swf_sample	=	1	if	ccode	==	850
replace	swf_sample	=	1	if	ccode	==	645
replace	swf_sample	=	1	if	ccode	==	325
replace	swf_sample	=	1	if	ccode	==	705
replace	swf_sample	=	1	if	ccode	==	946
replace	swf_sample	=	1	if	ccode	==	820
replace	swf_sample	=	1	if	ccode	==	435
replace	swf_sample	=	1	if	ccode	==	135
replace	swf_sample	=	1	if	ccode	==	101
replace	swf_sample	=	1	if	ccode	==	712
replace	swf_sample	=	1	if	ccode	==	920
replace	swf_sample	=	1	if	ccode	==	475
replace	swf_sample	=	1	if	ccode	==	95
replace	swf_sample	=	1	if	ccode	==	910
replace	swf_sample	=	1	if	ccode	==	670
replace	swf_sample	=	1	if	ccode	==	433
replace	swf_sample	=	1	if	ccode	==	701
replace	swf_sample	=	1	if	ccode	==	375
label var swf_sample "Identifier for countries that have created SWFs during the sample period"

by ccode: egen total_party_yr_2 = sum(party_yr) if swf==0 & swf_sample ==1 
*this generates the sum of years under party autocracy prior to creating a SWF, for the sample of countries that eventually creates an SWF

by ccode: egen last_yr_2 = max(year) if swf==0 &swf_sample==1
*last_yr_2 is the final year of the regime before an SWF was created, for the sample of countries that did create them
by ccode: gen total_yr_2 = (last_yr_2 - first_yr)+1 if swf_sample==1

*now generate the party share variable for only those in the SWF sample
by ccode: gen party_share_2 = total_party_yr_2 / total_yr_2 
harmby party_share_2, by(ccode)

*now want to gen a new variable that uses party_share for non-SWF countries, and party_share_2 for countries that created a SWFs

by ccode: gen party_share_revised = party_share if swf_sample==0
by ccode: replace party_share_revised = party_share_2 if swf_sample==1

tab party_share_revised, mis
*note that the missing values here are for autocracies that had an SWF in the first year of their existence in the dataset
*these are Venezuela, Kuwait, and UAE. Because they had an SWF on the first year, they don't have any year prior to SWF data to report
replace party_share_revised = 0 if country=="Venezuela" | country=="Kuwait" | country=="United Arab Emirates"
tab party_share_revised, mis

ttest party_share_revised if year==last_yr, by(swf)


*********************
*Measure of policy-making autonomy (main IV)
*********************

alpha partyrbrstmp officepers partyexcom_pers createparty, item generate(party_pers)
label var party_pers "policy-making autonomy"

// An alternative examination with factor analysis
factor partyrbrstmp officepers partyexcom_pers createparty, pcf
rotate
predict factor1
label var factor1 "Single factor of policy-making autonomy"

*Generate one year lags of the above variables, since underlying data measures presence of traits as of Jan 1
tsset gwf_leaderid year

bysort gwf_leaderid: gen lag_party_pers = l.party_pers
label var lag_party_pers "policy-making autonomy, one year lag" 

bysort gwf_leaderid: gen lag_factor1 = l.factor1
label var lag_factor1 "Factor Analysis policy-making autonomy, one yr lag"

*generate the lagged versions of these individual components for robustness analysis
bysort gwf_leaderid: gen lag_partystamp = l.partyrbrstmp
bysort gwf_leaderid: gen lag_office = l.officepers
bysort gwf_leaderid: gen lag_excom = l.partyexcom_pers
bysort gwf_leaderid: gen lag_create = l.createparty


**********************
*Other economic/political variables
**********************
*Haber and Menaldo reserves_billions variable stops at 2008; use reserves_billions_update for 1980-2010, Haber and Menaldo for 1960-1979
gen reserves_new = reserves_billions
replace reserves_new = reserves_billions_update if year>2008
tab year if reserves_new!=.
label var reserves_new "Proven oil reserves in billions of barrels"

*re-scale reserves_new so that the regression coefficients are not so small
gen reserves_new_rescale = reserves_new/100
label var reserves_new_rescale "Proven oil reserves in hundreds of billions of barrels"

*there is one obs with a negative value of forex; drop this so we can take log transformation
*I'm taking the natural log of foreign exchange, given its extremely skewed distribution
drop if forex<0
gen logforex = ln(forex)
label var logforex "Foreign exchange (log)"

sum gwf_leader_duration
hist gwf_leader_duration, freq
gen log_dur = ln(gwf_leader_duration)
sum log_dur
hist log_dur, freq
label var log_dur "GWF Leader duration, log"

****************************************************************

*Begin survival analysis

****************************************************************


*********************
*Figure 1 Models and Plot
*********************

stset year, id(gwf_leaderid) failure(swf==1)
 
*Model 1 (main IV and 2 critical controls: size of economy and oil reserves; referred to as "Baseline Specification"")
stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale, nohr vce (cluster gwf_leaderid)
estimates store m1
*all three together (Model 2)
stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale log_dur gwf_party, nohr vce (cluster gwf_leaderid)
estimates store m2
*add GDPgrowth, forex and trade (Model 3)
stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale log_dur gwf_party GDPgrowth logforex trade_wdi, nohr vce (cluster gwf_leaderid)
estimates store m3

*Figure 1
coefplot m1, xline(0) levels(95 90) msize(large) bylabel("1") ///
	|| m2, xline(0) levels(95 90) msize(large) bylabel("2") ///
	|| m3, xline(0) levels(95 90) msize(large) bylabel("3") ///
	coeflabels(lag_party_pers = "Policy-making autonomy" lngdp_wdi_pw = "GDP (log)" ///
	reserves_new_rescale = "Proven oil reserves" leg = "Competitive legislature" gwf_party = "Party regime" ///
	log_dur = "Leader duration (log)" trade_wdi = "Trade as % of GDP"  logforex = "Foreign exchange (log)" GDPgrowth = "GDP growth, annual %", labsize(med)) ///
	byopts(row(1) note(" " "{it:Note}: Sample is autocratic leader-years, 1960-2010. Standard errors clustered on individual leaders." ///
	"Models 1-2 have 301 subjects, 16 failures, and 2,650 obs. Model 3 has 251 subjects, 13 failures, and 2002 obs.", size(small)) ///
	title("Figure 1: Survival Models of Autocratic SWF Creation" "Estimates Reported as Coefficients, with 95 and 90% CIs" " " , pos(12))) ciopts(lwidth(*1 *2)) ///
	aspectratio(2) scheme(plotplain) 
	
	
**********************
*Figure 2 Models and Plot
**********************	

*control for current account balance
stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale log_dur gwf_party cab_shareGDP, nohr vce (cluster gwf_leaderid)
est store cab1

stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale log_dur gwf_party GDPgrowth logforex trade_wdi cab_shareGDP, nohr vce (cluster gwf_leaderid)
est store cab2


*Drop obs. that exit sample because they democratize (have to id these as gwf_case_fail == 1 (for general regime failure) and gwf_subsregime =1 is for trans to democracy)
*in other words, this drops from the analysis regimes that transitioned from autocracy to democracy in the next year, or "regimes on the cusp of democratization"

stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale log_dur gwf_party if gwf_case_fail!=1 & gwf_fail_subsregime!=1, nohr vce (cluster gwf_leaderid)
estimates store m6 

stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale log_dur gwf_party logforex trade_wdi GDPgrowth if gwf_case_fail!=1 & gwf_fail_subsregime!=1, nohr vce (cluster gwf_leaderid)
estimates store m7

*Control for prior episodes of democracy 

*Requires id'ing the countries that had some prior democratic regime
gen priordem = 0
replace priordem = 1 if gwf_prior=="democracy"
bysort ccode: gen sumdem = sum(priordem)
*when sumdem > 0, there was some prior regime, within the country, that was democratic

stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale log_dur gwf_party priordem, nohr vce (cluster gwf_leaderid)
estimates store m8 

stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale log_dur gwf_party priordem GDPgrowth logforex trade_wdi, nohr vce (cluster gwf_leaderid)
estimates store m9

*Control for past regime failures by creating a variable that captures the number of past regime failures and including this in the model

*by ccode, sum the gwf_case_fail variable. 
bysort ccode: egen fail_total = sum(gwf_case_fail) 

stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale log_dur gwf_party fail_total, nohr vce (cluster gwf_leaderid)
estimates store m10

stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale log_dur gwf_party logforex trade_wdi GDPgrowth fail_total, nohr vce (cluster gwf_leaderid)
estimates store m11

**Change unit of analysis to regime-year, and cluster at the regime level
*baseline, main, and econ specifications, with regime_year as unit of analysis and level for clustering

stset year, id(gwf_caseid) failure(swf==1)
stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale , nohr vce (cluster gwf_caseid)
estimates store m12
stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale log_dur gwf_party, nohr vce (cluster gwf_caseid)
estimates store m13
stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale log_dur gwf_party logforex trade_wdi GDPgrowth, nohr vce (cluster gwf_caseid)
estimates store m14

*Create the tabular results table(s) reported in the appendix
esttab m1 m2 m3 cab1 cab2 m6 m7 m8 m9 m10 m11 m12 m13 m14 using robust.rtf, se label star(+ 0.10 * 0.05 ** 0.01) replace


***Figure 2 plots the estimated coefficient from main IV across 12 different specifications

coefplot (m2, pstyle(p1) msize(large)) (m3, pstyle(p1) msize(large)) (cab1, pstyle(p1) msize(large)) (cab2, pstyle(p1) msize(large)) (m6, pstyle(p1) msize(large)) (m7, pstyle(p1) msize(large)) (m8, pstyle(p1) msize(large)) (m9, pstyle(p1) msize(large)) (m10, pstyle(p1) msize(large)) (m11, pstyle(p1) msize(large)) (m12, pstyle(p1) msize(large)) (m13, pstyle(p1) msize(large)) (m14, pstyle(p1) msize(large)), horizontal keep(lag_party_pers) xline(0) scheme(plotplain) coeflabels(m2 = "Model 2  (Fig. 1)" m3 = "Model 3 (Fig. 1)" cab1 = "M2, control for Current Acct Balance" cab2 = "M3, control for Current Acct Balance" m6 = "M2, drop democratizing regimes" m7 = "M3, drop democratizing regimes" m8 = "M2, control for prior democracy" m9 = "M3, control for prior democracy" m10 = "M2, control for count of past failures" m11 = "M3, control for count of past failures" m12 = "M1, cluster on regimes" m13 = "M2, cluster on regimes" m14 = "M3, cluster on regimes" , wrap(45)) aseq swapnames legend(off) order(m2 m3 . cab1 cab2 . m6 m7 . m8 m9 . m10 m11 . m12 m13 m14) title("Figure 2: Robustness of Main Result" " ") xlabel(-1(1)5)  xtitle("Estimated {it:Policy-making autonomy} coefficient" "and 90% (thick) and 95% (thin) CIs from survival models", size(small)) levels(95 90) note(" " "{it:Note}: M1 = Model 1 (Fig. 1) specification, M2 = Model 2 (Fig. 1) specification, M3 = Model 3 (Fig. 1)" "specification.  Sample details for all remaining models reported in tabular results in appendix.", size(small) pos(7)) 


*******************
*Additional materials for appendix
*******************

*Some additional descriptives on the key IV
*re-run baseline to generate e(sample)
stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale, nohr vce (cluster gwf_leaderid)
hist lag_party_pers if e(sample), freq bin(4) 
tab lag_party_pers if e(sample)
sum lag_party_pers if e(sample)

hist lag_party_pers if e(sample), percent discrete gap(5) xlabel(0 .25 .5 .75 1) xtitle("Observed values of {it:Policy-making autonomy}") aspectratio(.75) scheme(plotplain) title("Figure A1: Distribution of" "{it:Policy-making autonomy} in Baseline Sample" " ") note(" " "{it:Note}: Variable is linear combination of 4 indicators of extent to which" "an autocratic leader has consolidated power over their party system." "Data from Geddes, Wright, and Frantz (2018).")


**histograms of lag_party_pers  by different GWF regime types
gen gwf_combined = .
replace gwf_combined = 0 if gwf_party==1
replace gwf_combined = 1 if gwf_personal==1
replace gwf_combined = 2 if gwf_monarchy==1
replace gwf_combined = 3 if gwf_military==1
tab gwf_combined, mis

label define gwf_combined_1 0 "Party-Based" 1 "Personalist" 2 "Monarchy" 3 "Military"
label values gwf_combined gwf_combined_1

twoway (hist lag_party_pers if e(sample),  percent discrete gap(5)), xlabel(0 .25 .5 .75 1) by(gwf_combined, note("{it:Note}: Variable is linear combination of 4 indicators of" "extent to which an autocratic leader has consolidated power" "over their party system. Data from Geddes, Wright, and" "Frantz (2018). Regime categories from Geddes, Wright," "and Frantz (2014).") title("Figure A2: Distribution of" "{it:Policy-making autonomy}" "Across Autocratic Regime Types"))  xtitle("Observed values of {it:Policy-making autonomy}") aspectratio(.75) scheme(plotplain)


*Some descriptives of the entire sample (using baseline specification)
sum swf lag_party_pers lngdp_wdi_pw reserves_new_rescale log_dur gwf_party GDPgrowth logforex trade_wdi cab_shareGDP priordem fail_total if e(sample)

**Using alternative measures of resource wealth

*	1) WDI total natural resource rents as % GDPgrowth
*	2) Ross/Mahdavi per-capita value of oil and gas exports 
*	3) Ross/Mahdavi per-capita value of oil exports

*re-scale Ross/Mahdavi variables so CIs show up on plot; they are in per-capita terms already; divide by 1,000
gen oil_gas_rescale = net_oil_gas_exports_valuepop/1000
gen oil_rescale = net_oil_exports_valuepop/1000

label var oil_gas_rescale "Oil & gas export value (per-capita, 000s)"
label var oil_rescale "Oil export value (per-capita, 000s)"

gen total_rents_rescale = total_res_rents_WBopen/100
label var total_rents_rescale "Total Natural Resource Rents (% GDP)"
*simply rescaling so that CIs show up on the plot

*estimate models using each of these three alternative resource wealth measures
stcox lag_party_pers lngdp_wdi_pw total_rents_rescale log_dur gwf_party GDPgrowth logforex trade_wdi, nohr vce (cluster gwf_leaderid)
est store x2

stcox lag_party_pers lngdp_wdi_pw oil_gas_rescale log_dur gwf_party GDPgrowth logforex trade_wdi, nohr vce (cluster gwf_leaderid)
est store x4  

stcox lag_party_pers lngdp_wdi_pw oil_rescale log_dur gwf_party GDPgrowth logforex trade_wdi, nohr vce (cluster gwf_leaderid)
est store x6

coefplot x2, xline(0) levels(95 90) msize(large) bylabel("1") ///
	|| x4, xline(0) levels(95 90) msize(large) bylabel("2") ///
	|| x6, xline(0) levels(95 90) msize(large) bylabel("3") ///
	coeflabels(lag_party_pers = "Policy-making autonomy" lngdp_wdi_pw = "GDP (log)" ///
	total_rents_rescale = "{bf:Alternative 1:} Total Nat. Resource Rents (% GDP)" leg = "Competitive legislature" gwf_party = "Party regime" ///
	log_dur = "Leader duration (log)" trade_wdi = "Trade as % of GDP"  logforex = "Foreign exchange (log)" GDPgrowth = "GDP growth, annual %" oil_rescale = "{bf:Alternative 2:} Oil export value (per-capita 000s)" ///
	oil_gas_rescale = "{bf:Alternative 3:} Oil & gas export value (per-capita 000s)", labsize(med)) ///
	byopts(row(1) note(" " "{it:Note}: Sample is autocratic leader-years, 1960-2010. Standard errors clustered on individual leaders." ///
	"Model 1 has 220 subjects, 14 failures, and 1,780 obs. Model 2 has 110 subjects, 11 failures, and 782 obs." "Model 3 has 127 subjects, 11 failures, and 975 obs.", size(small)) ///
	title("Figure XXX: Survival Models of Autocratic SWF Creation" " " "Alternative Measures of Resource Rents" " " , pos(12))) ciopts(lwidth(*1 *2)) ///
	aspectratio(2) scheme(white_ptol) order(lag_party_pers lngdp_wdi_pw total_rents_rescale oil_gas_rescale oil_rescale)
	
*generate the table for this	
esttab x2 x4 x6 using alt_res.rtf, se label star(+ 0.10 * 0.05 ** 0.01) replace
		
*generate a geographical region varaible to create regional fixed effects
kountry ccode, from(cown) geo(cow)
gen cow_reg_ordered = .
replace cow_reg_ordered = 1 if GEO=="Africa"
replace cow_reg_ordered = 2 if GEO=="Asia"
replace cow_reg_ordered = 3 if GEO=="Europe"
replace cow_reg_ordered = 4 if GEO=="Middle East"
replace cow_reg_ordered = 5 if GEO=="North and South America"


stcox lag_party_pers lngdp_wdi_pw reserves_new_rescale log_dur gwf_party GDPgrowth logforex trade_wdi i.cow_reg_ordered, nohr vce (cluster gwf_leaderid)	
est store x7

*New Appendix Table A5 - regional fixed effects (COW coding) and three alternative measures of resource richness
esttab x7 x2 x4 x6 using alt_res.rtf, se label star(+ 0.10 * 0.05 ** 0.01) replace


